
import java.io.*;
import java.net.*;
import java.util.*;

import javax.swing.Icon;
import javax.swing.ImageIcon;


class GoogleSearchWorker extends SearchWorker
{
    private final static String template = 
	"<p><A HREF=@(any)http://@(any=url)>@(any=title)</A>@(any)</font></font>";

    private final static PageParser parser = new PageParser(template);

    private final static Icon icon = new ImageIcon("images/google.gif");

    public GoogleSearchWorker(Search search, String query) {
	super(search, query);
    }

    protected PageParser getPageParser() {
	return parser;
    }

    /**
     * Google hits are numbered from 1 rather than 0
     */
    protected URL getPageURL(String q, int t) throws MalformedURLException {
	String queryURLString = 
	    "http://www.google.com/search?q=" + q + "&start=" + (t + 1) + "&num=10";
	return new URL(queryURLString);
    }

    public String getSiteName() {
	return "Google";
    }

    public Icon getSiteIcon() {
	return icon;
    }
}
